import sys
sys.path.append('../kernel')
from model import Model
class WeatherModel(Model):
    def __init__(self):
        #链接数据库
        super().__init__()
    #获取气象数据执行的
    def add_city_weather(self,data):
        # 执行查询
        try:
            sql = "INSERT INTO weather SET c_id='%d',tmp_max='%d',tmp_min='%d',tmp='%d',cond='%d',wind='%s',create_time='%d'" % (data['c_id'],data['tmp_max'],data['tmp_min'],data['tmp'],data['cond'],data['wind'],data['create_time'])
            self.cursor.execute(sql)
            self.conn.commit()  # 提交
            return True
        except:
            return False
    def __del__(self):
        #计数数据库链接
        self.cursor.close()
        self.conn.close()


